Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various additions to PointShop items #298

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

TheWhichDoctor
Copy link

  • Added check if user owns a weapon, then gives ammo if they do
  • Added settings for preset BodyGroup and Skin settings.
    To use:
  1. Add ITEM:BodyGroup(modifications) function to ITEM (Replace "Preset x" with name of the preset in DERMA)
function ITEM:BodyGroup(modifications)
    Derma_Query("Choose BodyGroup", "",
        "Preset 1", function()
            modifications.group = 0
            PS:SendModifications(self.ID, modifications)
        end,
        "Preset 2", function()
            modifications.group = 1
            PS:SendModifications(self.ID, modifications)
        end,
        "Preset 3", function()
            modifications.group = 2
            PS:SendModifications(self.ID, modifications)
        end,
        "Preset 4", function()
            modifications.group = 3
            PS:SendModifications(self.ID, modifications)
        end
    )
end
  1. Add functionality to ITEM:OnEquip(modifications) function. If Playermodel supports skins you can apply them too.
    Example:
function ITEM:OnEquip(ply, modifications)
    if not ply._OldModel then
        ply._OldModel = ply:GetModel()
    end
    timer.Simple(1, function() ply:SetModel(self.Model) end)
    if modifications.group ~= nil then
        if modifications.group == 0 then
            ply:SetSkin(0)
            ply:SetBodygroup(2,0)
        elseif modifications.group == 1 then
            ply:SetSkin(0)
            ply:SetBodygroup(2,1)
        elseif modifications.group == 2 then
            ply:SetSkin(1)
            ply:SetBodygroup(2,2)
        elseif modifications.group == 3 then
            ply:SetSkin(1)
            ply:SetBodygroup(2,3)
        end
    end
end
  1. (OPTIONAL) Reset player BodyGroups and Skins to default - not doing this caused issues for Prop Hunt when players switched teams and respawned.
function ITEM:OnHolster(ply)
    ply:SetSkin(0)
    ply:SetBodygroup(2,0)
	if ply._OldModel then
		ply:SetModel(ply._OldModel)
	end
end
  • Added playermodel colors (using modifications.color caused issues when I wrote this ~2 years ago). This was written to iverwrite team color being used for the model color on compatible models.
  1. Add following code to function "ITEM:Modify"
function ITEM:Modify(modifications)
	PS:ShowPlyColorChooser(self, modifications)
end
  1. Add code to set player's color to it.
function ITEM:OnEquip(ply, modifications)
    if not ply._OldModel then
        ply._OldModel = ply:GetModel()
    endle(1, function() ply:SetModel(self.Model) end)
    if modifications.plycolor ~= nil then
        local c = modifications.plycolor
        local r = c["r"]/255
        local g = c["g"]/255
        local b = c["b"]/255
        ply:SetPlayerColor( Vector(r, g, b) )
    end
end
  • PointShop preview panel automatically updates to the BodyGroups, Skins and Colors.
  • I used preset options in DERMA queries instead of sliders for each BodyGroup (like you see in Sandbox) because some PlayerModels (mostly the vocaloids) could be set with unforeseen options like back of head missing or nsfw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant